package flc.ast.dialog;

import android.content.Context;
import android.view.Gravity;
import android.view.View;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.blankj.utilcode.util.FileUtils;
import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;

import flc.ast.R;
import flc.ast.databinding.DialogInfoStyleBinding;
import stark.common.basic.base.BaseSmartDialog;
import stark.common.basic.utils.MediaUtil;

public class InfoDialog extends BaseSmartDialog<DialogInfoStyleBinding> {
    public String path;

    public InfoDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getGravity() {
        return Gravity.BOTTOM;
    }

    @Override
    protected boolean canceledOnTouchOutside() {
        return true;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_info_style;
    }

    @Override
    protected void initView(View view) {
        Glide.with(getContext()).load(path).into(mDataBinding.ivFileImg);
        mDataBinding.tvName.setText(FileUtils.getFileName(path));
        mDataBinding.tvDate.setText(TimeUtils.millis2String(FileUtils.getFileLastModified(path), "yyyy/MM/dd日 HH:mm"));
        mDataBinding.tvFileSize.setText(ConvertUtils.byte2FitMemorySize(FileUtils.getLength(path), 0));
        mDataBinding.tvFileName.setText(FileUtils.getFileNameNoExtension(path));
        mDataBinding.tvSize.setText(FileUtils.getSize(path));
        mDataBinding.tvLocation.setText(path);
        mDataBinding.tvModificationTime.setText(TimeUtils.millis2String(FileUtils.getFileLastModified(path), "yyyy/MM/dd日 HH:mm"));
    }
}
